﻿/****************************************************************
*   作者：qq918
*   创建时间：2017/12/20 13:43:59
*   描述说明：
*   
*   MD5帮助类
*****************************************************************/

using System.IO;
using System.Security.Cryptography;

namespace Model
{

    public static class MD5Helper
    {
        /// <summary>
        /// 计算文件的MD5
        /// </summary>
        /// <param name="filePath"></param>
        /// <returns></returns>
        public static string FileMD5(string filePath)
        {
            byte[] retVal;
            using (FileStream fs = new FileStream(filePath,FileMode.Open))
            {
                MD5 md5 = new MD5CryptoServiceProvider();
                retVal = md5.ComputeHash(fs);
            }

            return retVal.ToHex();
        }


    }
}
